﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using TruckingApplication.Dal.EntityModels;

namespace TruckingApplication.Web.Infrastructure
{
    public class Utilities
    {
        public static ORDER oldOrder { get; set; }
        public static List<string> OrderComparer(ORDER newOrder)
        {
            var results = new List<string>();
            
            // What changed about the order

            // Gross
            if(oldOrder.gross != newOrder.gross)
                results.Add(string.Format("The gross changed from {0} to {1}.",oldOrder.gross, newOrder.gross));

            // Net
            if (oldOrder.net != newOrder.net)
                results.Add(string.Format("The net changed from {0} to {1}.", oldOrder.net, newOrder.net));

            // Carrier Rate
            if (oldOrder.carrierRate != newOrder.carrierRate)
                results.Add(string.Format("The carrier rate changed from {0} to {1}.", oldOrder.carrierRate, newOrder.carrierRate));

            // Max
            if (oldOrder.max != newOrder.max)
                results.Add(string.Format("The max changed from {0} to {1}.", oldOrder.max, newOrder.max));

            // Net
            if (oldOrder.paidStatus != newOrder.paidStatus)
                results.Add(string.Format("The paid status changed from {0} to {1}.", oldOrder.paidStatus, newOrder.paidStatus));
            
            // Due Date
            if (oldOrder.dueDate != newOrder.dueDate)
                results.Add(string.Format("The due date changed from {0} to {1}.", oldOrder.dueDate, newOrder.dueDate));
            
            // mileage
            if (oldOrder.mileage != newOrder.mileage)
                results.Add(string.Format("The mileage changed from {0} to {1}.", oldOrder.mileage, newOrder.mileage));
            
            // Dead Head Mileage
            if (oldOrder.deadHeadMileage != newOrder.deadHeadMileage)
                results.Add(string.Format("The dead head mileage changed from {0} to {1}.", oldOrder.deadHeadMileage, newOrder.deadHeadMileage));

            // Quick Pay
            if (oldOrder.quickPay != newOrder.quickPay)
                results.Add(string.Format("The quick pay changed from {0} to {1}.", oldOrder.quickPay, newOrder.quickPay));

            // Lumper Fee
            if (oldOrder.lumperFee != newOrder.lumperFee)
                results.Add(string.Format("The lumper fee changed from {0} to {1}.", oldOrder.lumperFee, newOrder.lumperFee));

            // Pickup City
            if (oldOrder.pickupCity != newOrder.pickupCity)
                results.Add(string.Format("The pickup city changed from {0} to {1}.", oldOrder.pickupCity, newOrder.pickupCity));

            // Pickup State
            if (oldOrder.pickupState != newOrder.pickupState)
                results.Add(string.Format("The pickup state changed from {0} to {1}.", oldOrder.pickupState, newOrder.pickupState));

            // Drop Off City
            if (oldOrder.dropOffCity != newOrder.dropOffCity)
                results.Add(string.Format("The drop off city changed from {0} to {1}.", oldOrder.dropOffCity, newOrder.dropOffCity));
            
            // Drop Off State
            if (oldOrder.dropOffState != newOrder.dropOffState)
                results.Add(string.Format("The drop off state changed from {0} to {1}.", oldOrder.dropOffState, newOrder.dropOffState));

            // Notes
            if (oldOrder.notes != newOrder.notes)
                results.Add(string.Format("The notes changed from {0} to {1}.", oldOrder.notes, newOrder.notes));

            // Order Status
            if(oldOrder.ORDER_STATUS.status != newOrder.ORDER_STATUS.status)
                results.Add(string.Format("The order status changed from {0} to {1}.", oldOrder.ORDER_STATUS.status, newOrder.ORDER_STATUS.status));

            return results;
        }
    }
}